let MyOptionModel = require('../model').myOptionModel;
let DaoTool = require('../lib/daoTool');
//创建
exports.createMyOption = function (conn, params) {
    return new Promise(function (resolve, reject) {
        conn.query("insert into my_option set ?;", [DaoTool.generateModelObject(params, MyOptionModel, 'create')], function (err, result) {
            printLog("=createMyOption=", this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};
//更新
exports.updateMyOption = function (conn, params) {
    return new Promise(function (resolve, reject) {
        let updateParams = DaoTool.generateModelObject(params, MyOptionModel, 'update');
        if (JSON.stringify(updateParams) == "{}"){
            resolve();
        }else{
            conn.query("update my_option set ? where openid=?;", [updateParams, params.openid], function (err, result) {
                printLog("=updateMyOption=", this.sql);
                if (err) reject(err);
                resolve(result)
            });
        }
    });
};
exports.queryMyOption = function (params, conn) {
    return new Promise(function (resolve, reject) {
        let sql = "select MyField0,MyField1,MyField2,MyField3,MyField4,MyField5,MyField6,MyField7,MyField8,MyField9,MyField10,MyField11,MyField12,MyField13,MyField14,MyField15,MyField16,MyField17,MyField18,MyField19,MyField20,MyField21,MyField22,MyField23,MyField24,MyField25,MyField26,MyField27,MyField28,MyField29,MyField30,MyField31,MyField32,MyField33,MyField34,MyField35,MyField36,MyField37,MyField38,MyField39,MyField40,MyField41,MyField42,MyField43,MyField44,MyField45,MyField46,MyField47,MyField48,MyField49,MyField50,MyField51,MyField52,MyField53,MyField54,MyField55,MyField56,MyField57,MyField58,MyField59,MyField60,MyField61,MyField62,MyField63,MyField64,MyField65,MyField66,MyField67,MyField68,MyField69,MyField70,MyField71,MyField72,MyField73,MyField74,MyField75,MyField76,MyField77,MyField78,MyField79,MyField80,MyField81,MyField82,MyField83,MyField84,MyField85,MyField86,MyField87,MyField88,MyField89,MyField90,MyField91,MyField92,MyField93,MyField94,MyField95,MyField96,MyField97,MyField98,MyField99,MyField100,MyField101,MyField102,MyField103,MyField104,MyField105,MyField106,MyField107,MyField108,MyField109,MyField110,MyField111,MyField112,MyField113,MyField114,MyField115,MyField116,MyField117,MyField118,MyField119,MyField120,MyField121,MyField122,MyField123,MyField124,MyField125,MyField126,MyField127,MyField128,MyField129,MyField130,MyField131,MyField132,MyField133,MyField134,MyField135,MyField136,MyField137,MyField138,MyField139,MyField140,MyField141,MyField142,MyField143,MyField144,MyField145,MyField146,MyField147,MyField148,MyField149,MyField150,MyField151,MyField152 from my_option where OpenId = ?;";
        conn.query(sql, [params.openid], function (err, result) {
            printLog(this.sql);
            if (err) reject(err);
            resolve(result)
        });
    });
};
